/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    cn-beijing = 'gpdb.aliyuncs.com',
    cn-hangzhou = 'gpdb.aliyuncs.com',
    cn-shanghai = 'gpdb.aliyuncs.com',
    cn-shenzhen = 'gpdb.aliyuncs.com',
    cn-hongkong = 'gpdb.aliyuncs.com',
    ap-southeast-1 = 'gpdb.aliyuncs.com',
    us-west-1 = 'gpdb.aliyuncs.com',
    us-east-1 = 'gpdb.aliyuncs.com',
    cn-hangzhou-finance = 'gpdb.aliyuncs.com',
    cn-shanghai-finance-1 = 'gpdb.aliyuncs.com',
    cn-shenzhen-finance-1 = 'gpdb.aliyuncs.com',
    cn-qingdao = 'gpdb.aliyuncs.com',
    cn-north-2-gov-1 = 'gpdb.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('gpdb', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DescribeDBInstanceForDmsRequest {
  DBInstanceId?: string(name='DBInstanceId'),
  host?: string(name='Host', example='gp-bp12ga6v69h86****-master.gpdb.rds.aliyuncs.com'),
  ownerId?: long(name='OwnerId'),
  port?: long(name='Port', example='5432'),
}

model DescribeDBInstanceForDmsResponseBody = {
  code?: string(name='Code', example='"200"'),
  count?: long(name='Count', example='1'),
  httpStatusCode?: int32(name='HttpStatusCode', example='200'),
  instance?: {
    aliUid?: string(name='AliUid', example='253460731706911258'),
    bid?: string(name='Bid', example='*****'),
    connectionString?: string(name='ConnectionString', example='gp-bp12ga6v69h86****-master.gpdbmaster.singapore.rds.aliyuncs.com'),
    dbInstanceName?: string(name='DbInstanceName', example='gp-bp12ga6v69h86****'),
    dbType?: string(name='DbType', example='gpdb'),
    description?: string(name='Description', example='”“'),
    instanceNetworkType?: string(name='InstanceNetworkType', example='vpc'),
    port?: string(name='Port', example='5432'),
    region?: string(name='Region', example='ap-southeast-1'),
    vSwitchId?: string(name='VSwitchId', example='vsw-bp1cpq8mr64paltkb****'),
    version?: string(name='Version', example='6.0'),
    vpcCloudInstanceId?: string(name='VpcCloudInstanceId', example='vpc-bp19ame5m1r3oejns****'),
    vpcId?: string(name='VpcId', example='vpc-bp19ame5m1r3oejns****'),
    vpcIp?: string(name='VpcIp', example='172.16.0.140'),
  }(name='Instance'),
  message?: string(name='Message', example='""'),
  requestId?: string(name='RequestId', example='B4CAF581-2AC7-41AD-8940-D56DF7AADF5B'),
  success?: boolean(name='Success', example='true'),
}

model DescribeDBInstanceForDmsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeDBInstanceForDmsResponseBody(name='body'),
}

async function describeDBInstanceForDmsWithOptions(request: DescribeDBInstanceForDmsRequest, runtime: Util.RuntimeOptions): DescribeDBInstanceForDmsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.DBInstanceId)) {
    query['DBInstanceId'] = request.DBInstanceId;
  }
  if (!Util.isUnset(request.host)) {
    query['Host'] = request.host;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.port)) {
    query['Port'] = request.port;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDBInstanceForDms',
    version = '2019-06-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeDBInstanceForDms(request: DescribeDBInstanceForDmsRequest): DescribeDBInstanceForDmsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDBInstanceForDmsWithOptions(request, runtime);
}

model DescribeDBInstanceSecurityIpsRequest {
  instanceId?: string(name='InstanceId', example='gp-xxxxxxxxxxxx'),
  ownerId?: long(name='OwnerId'),
}

model DescribeDBInstanceSecurityIpsResponseBody = {
  code?: string(name='Code', example='"200"'),
  count?: long(name='Count', example='2'),
  httpStatusCode?: int32(name='HttpStatusCode', example='200'),
  message?: string(name='Message', example='""'),
  requestId?: string(name='RequestId', example='B4CAF581-2AC7-41AD-8940-D56DF7AADF5B'),
  result?: [ 
    {
      groupName?: string(name='GroupName', example='default'),
      whiteList?: [ string ](name='WhiteList'),
    }
  ](name='Result'),
  success?: boolean(name='Success', example='true'),
}

model DescribeDBInstanceSecurityIpsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeDBInstanceSecurityIpsResponseBody(name='body'),
}

async function describeDBInstanceSecurityIpsWithOptions(request: DescribeDBInstanceSecurityIpsRequest, runtime: Util.RuntimeOptions): DescribeDBInstanceSecurityIpsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDBInstanceSecurityIps',
    version = '2019-06-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeDBInstanceSecurityIps(request: DescribeDBInstanceSecurityIpsRequest): DescribeDBInstanceSecurityIpsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDBInstanceSecurityIpsWithOptions(request, runtime);
}

model DescribeDBInstancesForDmsRequest {
  aliUid?: long(name='AliUid', example='253460731706911258'),
  ownerId?: long(name='OwnerId'),
}

model DescribeDBInstancesForDmsResponseBody = {
  code?: string(name='Code', example='"200"'),
  count?: long(name='Count', example='1'),
  httpStatusCode?: int32(name='HttpStatusCode', example='200'),
  instances?: [ 
    {
      aliUid?: string(name='AliUid', example='253460731706911258'),
      bid?: string(name='Bid', description='BID。', example='1234'),
      connectionString?: string(name='ConnectionString', example='gp-bp12ga6v69h86****-master.gpdbmaster.singapore.rds.aliyuncs.com'),
      dbInstanceName?: string(name='DbInstanceName', example='gp-bp12ga6v69h86****'),
      dbType?: string(name='DbType', example='gpdb'),
      description?: string(name='Description', example='""'),
      instanceNetworkType?: string(name='InstanceNetworkType', example='vpc'),
      port?: string(name='Port', example='5432'),
      region?: string(name='Region', example='ap-southeast-1'),
      vSwitchId?: string(name='VSwitchId', example='vsw-bp1cpq8mr64paltkb****'),
      version?: string(name='Version', example='6.0'),
      vpcCloudInstanceId?: string(name='VpcCloudInstanceId', example='vpc-bp19ame5m1r3oejns****'),
      vpcId?: string(name='VpcId', example='vpc-bp19ame5m1r3oejns****'),
      vpcIp?: string(name='VpcIp', example='172.16.0.140'),
    }
  ](name='Instances'),
  message?: string(name='Message', example='""'),
  requestId?: string(name='RequestId', example='B4CAF581-2AC7-41AD-8940-D56DF7AADF5B'),
  success?: boolean(name='Success', example='true'),
}

model DescribeDBInstancesForDmsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeDBInstancesForDmsResponseBody(name='body'),
}

async function describeDBInstancesForDmsWithOptions(request: DescribeDBInstancesForDmsRequest, runtime: Util.RuntimeOptions): DescribeDBInstancesForDmsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.aliUid)) {
    query['AliUid'] = request.aliUid;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDBInstancesForDms',
    version = '2019-06-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeDBInstancesForDms(request: DescribeDBInstancesForDmsRequest): DescribeDBInstancesForDmsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDBInstancesForDmsWithOptions(request, runtime);
}

model ModifyDBInstanceSecurityIpsRequest {
  aliUid?: long(name='AliUid', example='253460731706911258'),
  groupName?: string(name='GroupName', example='WhileListGroupName'),
  instanceId?: string(name='InstanceId', example='gp-bp12ga6v69h86****'),
  ownerId?: long(name='OwnerId'),
  whileList?: string(name='WhileList', example='"127.0.0.1,192.168.0.1"'),
}

model ModifyDBInstanceSecurityIpsResponseBody = {
  code?: string(name='Code', example='"200"'),
  httpStatusCode?: int32(name='HttpStatusCode', example='200'),
  message?: string(name='Message', example='Successful'),
  requestId?: string(name='RequestId', example='D4D4BE8A-DD46-440A-BFCD-EE31DA81C9DD'),
  success?: boolean(name='Success', example='true'),
}

model ModifyDBInstanceSecurityIpsResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ModifyDBInstanceSecurityIpsResponseBody(name='body'),
}

async function modifyDBInstanceSecurityIpsWithOptions(request: ModifyDBInstanceSecurityIpsRequest, runtime: Util.RuntimeOptions): ModifyDBInstanceSecurityIpsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.aliUid)) {
    query['AliUid'] = request.aliUid;
  }
  if (!Util.isUnset(request.groupName)) {
    query['GroupName'] = request.groupName;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.ownerId)) {
    query['OwnerId'] = request.ownerId;
  }
  if (!Util.isUnset(request.whileList)) {
    query['WhileList'] = request.whileList;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ModifyDBInstanceSecurityIps',
    version = '2019-06-20',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function modifyDBInstanceSecurityIps(request: ModifyDBInstanceSecurityIpsRequest): ModifyDBInstanceSecurityIpsResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyDBInstanceSecurityIpsWithOptions(request, runtime);
}

